#ifndef GL_RECT_HPP
#define GL_RECT_HPP
#include "GlPoint.hpp"



_GLBASE_BEGIN



class GlRect
{

private:

  GlPoint _leftTop;
  GlPoint _widthHeight;

public:

  GlRect (); 
  GlRect (const GlRect & arg); 
  GlRect (int x, int y, int width, int height); 
  GlRect (const GlPoint & leftTop, const GlPoint & widthHeight); 
  GlRect (const GlPoint & leftTop, int width, int height); 



  bool contains (const GlPoint & point) const;
  bool contains (const GlRect & rect) const;



  int getLeft () const; 
  int getTop () const; 
  int getRight () const; 
  int getBottom () const; 
  int getWidth () const; 
  int getHeight () const;
  GlPoint getLeftTop () const;
  GlPoint getLeftBottom () const;
  GlPoint getRightTop () const;
  GlPoint getRightBottom () const;
  GlPoint getWidthHeight () const;



  int setLeft (int left); 
  int setTop (int top); 
  int setWidth (int width); 
  int setHeight (int height); 

};  //end class GlRect







GlRect::GlRect () : _leftTop (), _widthHeight () {}



GlRect::GlRect (const GlRect & arg)
  : _leftTop (arg._leftTop), _widthHeight (arg._widthHeight) {}



GlRect::GlRect (int x, int y, int width, int height)
  : _leftTop (x, y), _widthHeight (width, height) {}



GlRect::GlRect (const GlPoint & leftTop, const GlPoint & widthHeight)
  : _leftTop (leftTop), _widthHeight (widthHeight) {}



GlRect::GlRect (const GlPoint & leftTop, int width, int height)
  : _leftTop (leftTop), _widthHeight (width, height) {}



bool GlRect::contains (const GlPoint & point) const
{
  if (point >= _leftTop && point <= getRightBottom ())
    return true;
  return false;
}



bool GlRect::contains (const GlRect & rect) const
{
  if (rect._leftTop >= _leftTop && rect.getRightBottom () <= getRightBottom ())
    return true;
  return false;
}



int GlRect::getLeft () const
{
  return _leftTop[0];
}



int GlRect::getTop () const
{
  return _leftTop[1];
}



int GlRect::getRight () const
{
  return _leftTop[0] + _widthHeight[0];
}



int GlRect::getBottom () const
{
  return _leftTop[1] + _widthHeight[1];
}



int GlRect::getWidth () const
{
  return _widthHeight[0];
}



int GlRect::getHeight () const
{
  return _widthHeight[1];
}



GlPoint GlRect::getLeftTop () const
{
  return _leftTop;
}



GlPoint GlRect::getLeftBottom () const
{
  return GlPoint (_leftTop[0], _leftTop[1] + _widthHeight[1]);
}



GlPoint GlRect::getRightTop () const
{
  return GlPoint (_leftTop[0] + _widthHeight[0], _leftTop[1]);
}



GlPoint GlRect::getRightBottom () const
{
  return GlPoint (_leftTop[0] + _widthHeight[0], _leftTop[1] + _widthHeight[1]);
}



GlPoint GlRect::getWidthHeight () const
{
  return _widthHeight;
}



int GlRect::setLeft (int left)
{
  _leftTop[0] = left;
}



int GlRect::setTop (int top)
{
  _leftTop[1] = top;
}



int GlRect::setWidth (int width)
{
  _widthHeight[0] = width;
}



int GlRect::setHeight (int height)
{
  _widthHeight[1] = height;
}



_GLBASE_END



#endif